package org.dhbw.cocktail;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import lombok.Data;

/**
 * Named Queries to Prevent SQL-Injection-like vulnerabilities
 */
@NamedQueries({
		@NamedQuery(name = "all_types", query = "SELECT t FROM jc_cocktail_type t"),
		@NamedQuery(name = "search_type", query = "SELECT t FROM jc_cocktail_type t WHERE UPPER(t.Name) LIKE :searchTerm ORDER BY t.Name ASC"),
		@NamedQuery(name = "search_type_by_id", query = "SELECT t FROM jc_cocktail_type t WHERE t.id=:searchTerm") })
		
/**
 * Represents a Type a cocktail can be
 * (e.g. Long Drinks, Shots etc...)
 * 
 * @author Roland von Werden
 * @version 0.1
 */
@Data
@Entity(name = "jc_cocktail_type")
public class CocktailType {
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id")
	private long Id;

	/** Name of the Type */
	@Column(name = "name")
	private String Name;

	/** Description of the Cocktail Type */
	@Column(name = "description", length = 4000)
	private String Description;

	public CocktailType() {
	}

	public CocktailType(String name, String desc) {
		this.Name = name;
		this.Description = desc;
	}
}
